﻿namespace LambdaCalc.Core.Tests

open System
open NUnit.Framework

open LambdaCalc.Core

[<TestFixture>]
type ``test core-operations: identifiers``() = 

    [<Test>]
    member test.``identifiers of one Atom is it's name``() =
        let input = Atom "a"
        let expectedOutput = Set.singleton "a"
        let result = Operations.identifiers input
        Assert.AreEqual(expectedOutput, result)
        
    [<Test>]
    member test.``identifiers of an abstraction is the argument and all identifiers of the body``() =
        let body = Atom "b"
        let input = Abstraction ("x", body)
        let expectedOutput = ["x"; "b"] |> Set.ofList
        let result = identifiers input
        Assert.AreEqual(expectedOutput, result)        

    [<Test>]
    member test.``identifiers of an application are the identifiers of the parts``() =
        let a = Atom "a"
        let b = Atom "b"
        let input = Application (a, b)
        let expectedOutput = ["a"; "b"] |> Set.ofList
        let result = identifiers input
        Assert.AreEqual(expectedOutput, result)